pp(node(Sem, Attr, Children)) :- pp(node(Sem, Attr, Children), ''), write('.\n').

pp(node(Sem, Attr, Children), Ind) :-
	write(Ind), write(Sem), write('\n'),
	concat(Ind, '  ', Ind2),
	pp_attr(Attr, Ind2),
	pp_children(Children, Ind2).

pp_attr([], _) :- true.
pp_attr([Key-Value | Tail], Ind) :-
	write(Ind), write('@'), write(Key), write('='), write(Value), write('\n'),
	pp_attr(Tail, Ind).

pp_children([], _) :- true.
pp_children([Key-Node | Tail], Ind) :-
	write(Ind), write('*'), write(Key), write('\n'),
	concat(Ind, '  ', Ind2),
	pp_nodes(Node, Ind2),
	pp_children(Tail, Ind).

pp_nodes([], _) :- true.
pp_nodes([Node | Tail], Ind) :- pp(Node, Ind), pp_nodes(Tail, Ind).
